<%- include ../common/header %>
<link rel="stylesheet" type="text/css" href="/css/common/reset.css" />
<link rel="stylesheet" type="text/css" href="/css/pay/buyApp.css" />
<div class="common_header">
	<div class="back" id="aaaa"><img src="/images/back.png" /></div>
	<span class="title">购买充值码</span>
</div>
<div class="boxwe" style="margin:0 auto;">
	<div style="position: inherit;left: 26px; margin-top: 20px; text-align: center;">
		<h2 style="color:red; font-size:2.5rem;">识别二维码后进入微信支付</h2>
		<br>
		<h3 style="font-size:2rem;">支持微信钱包快捷支付</h3>
	</div>
	<div id="wechatPayPic" style="position: inherit;left: 26px; margin-top: 20px; text-align: center;">
		<div id="loadingDivPay" style=" display:block;">
			<img src="/images/loading.gif">
		</div>
	</div>
</div>
<!--<a id="done" href="javascript:void(0);" class="login_con_btn_5" style="width: 48%;">完成充值</a>-->
<!--<div id="reset" class="login_con_btn_a" style="display: block;">重新支付</div>-->
<!--<div id="done" class="blue-btn" style="margin-top: 10px;margin-left: 3%;width: 94%;float: inherit;font-size:18px;">完成充值</div>-->
<!--<div id="reset" class="orange-btn" style="margin-top: 10px;margin-left: 3%;width: 94%;float: inherit;font-size:18px;">重新支付</div>-->

<%- include ../common/footer %>
<script src="/js/common/ajax.js"></script>
<script src="/js/common/yingSoftCookie.js"></script>
<script src="/js/common/yingSoftPrg.js"></script>
<script src="/js/libs/jquery-1.11.3.min.js"></script>
<script src="/js/appjs/jquery.qrcode-0.12.0.min.js"></script>

<script>
	function getCode() {
		var appEName = G_Prg.getQueryString('appEName');
		if(!appEName || appEName.toString().trim() === '') {
			appEName = G_Cookie.getAppEName();
		}

		var data = {
			"userID": G_Cookie.getUserID(),
			"userName": escape(G_Cookie.getUserName()),
			"softName": G_Prg.getQueryString('softName') === undefined ? escape(G_Cookie.getAppName()) : G_Prg.getQueryString('softName'),
			"softNameEname": appEName, //2014.11.17 由cookie获取改为先判断URL,如果没有才获取cookie
			"cookie": G_Cookie.getGuid(),
			"seriesID": G_Prg.getQueryString('appClassID'),
			"type": G_Prg.getQueryString('selectType'),
			"equipment": 'web_pc',
			//        "AgentNo":G_Cookie.getAgentCode(),
			"AgentNo": '888',
			"AgentSite": 'http://new.ksbao.com'
		}
		G_AjaxQrcode.post('/wxpay/sweepPayUrl', data, true, function(json) {
			if(json) {
				json = JSON.parse(json);
				if(json.status === 200) {
					G_Prg.$('loadingDivPay').style.display = 'none';
					$('#wechatPayPic').qrcode({
						"render": "image",
						"size": 300,
						"color": "#3a3",
						"text": json.data
					});
					return;
				}
				G_Prg.alert(json.msg, function() {
					back();
				})
			}

		});
	}

	function back() {
		window.location.href = 'buyApp?fromUrl=userHome.html&appEName=' + G_Cookie.getAppEName();
	}

	function convertCanvasToImage(canvas) {
		var image = new Image();
		image.src = canvas.toDataURL("image/png");
		return image;
	}
	//  G_Prg.$('done').onclick = function () {
	//      window.location.href='/doExam-index';
	//  }
	var backBtn = document.getElementById('aaaa');
	backBtn.onclick = function() {
			window.location.href = '/recharge/buyApp';
		}
		//  G_Prg.$('reset').onclick = function () {
		//      window.location.href = '/recharge/buyApp';
		//  }
	setTimeout('getCode()', 1000);
</script>